import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:tree_hole/letters/MyLetterPage.dart';
import 'treeHole/TreeHolePage.dart';
import 'letters/LetterPaperPage.dart';
import 'timeCapsule/TimePage.dart';

//主页

class HomePage extends StatelessWidget{
  final String token;
  HomePage(this.token);
  Widget build(BuildContext context){
    return Container(
      padding: EdgeInsets.only(left: 5,top: 5,right: 5,bottom: 15),
      child: new Container(
        padding: EdgeInsets.all(15),
        child: new Container(
          child: new Column(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              new Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  new Column(
                    children: [
                      SizedBox(height: 30),
                      LetterButton(this.token),
                      new Container(
                        width: 70,
                        child: Text('日记'),
                        alignment: Alignment.center,
                      ),//左上图标信
                    ],
                  ),
                  new Column(
                    children: [
                      SizedBox(height: 30),
                      new Container(
                        //padding: EdgeInsets.only(top: 20,right: 20),
                          child: TreeButton(this.token)
                      ),
                      new Container(
                        width: 70,
                        child: Text('树 洞'),
                        alignment: Alignment.center,
                      )
                    ],
                  ),//右上图标树洞
                ],
              ),
              new Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  new Column(
                    children: [
                      SizedBox(height: 10,width: 20),
                      new Container(
                        //padding: EdgeInsets.only(left: 20,bottom: 20),
                          child: TalkButton(this.token)
                      ),
                      new Container(
                        width: 70,
                        child: Text('论 坛'),
                        alignment: Alignment.center,
                      ),
                    ],
                  ),//左上图标论坛
                  new Column(
                    children: [
                      SizedBox(height: 10),
                      new Container(
                        //padding: EdgeInsets.only(right: 20,bottom: 20),
                          child: TimeButton(this.token)
                      ),
                      new Container(
                        width: 70,
                        child: Text('时间胶囊'),
                        alignment: Alignment.center,
                      ),
                    ],
                  ), //右上图标时间胶囊
                ],
              )
            ],
          ),
        ),
        decoration: BoxDecoration(
            image: new DecorationImage(
                fit: BoxFit.cover,
                image: new AssetImage('images/tree.jpg')
            )
        ),//中间背景树
      ),
    );
  }
}
//信按钮
class LetterButton extends StatelessWidget{
  final String token;
  LetterButton(this.token);
  Widget build (BuildContext context){
    return IconButton(
        padding: EdgeInsets.all(0),
        iconSize: 70,
        icon: Image.network('https://static.easyicon.net/preview/50/500446.gif'),
        onPressed:() {Navigator.push(context, new MaterialPageRoute(builder: (context) => new MyLetterPage(this.token))
        );
        }
    );
  }
}
//树洞按钮
class TreeButton extends StatelessWidget{
  final String token;
  TreeButton(this.token);
  Widget build (BuildContext context){
    return new IconButton(
        padding: EdgeInsets.all(0),
        iconSize: 70,
        icon: Image.network('https://static.easyicon.net/preview/128/1281812.gif'),
        onPressed:() {Navigator.push(context, new MaterialPageRoute(builder: (context) => new TreeHolePage(this.token))
        );
        }
    );
  }
}
//论坛按钮
class TalkButton extends StatelessWidget{
  final String token;
  TalkButton(this.token);
  Widget build (BuildContext context){
    return new IconButton(
        padding: EdgeInsets.all(0),
        iconSize: 70,
        icon: Image.network('https://static.easyicon.net/preview/109/1094170.gif'),
        onPressed:() {
          Fluttertoast.showToast(
            msg: "别点我！我没写！",
            backgroundColor: Colors.amber[50],
            textColor: Colors.black,
            fontSize: 15,
            toastLength: Toast.LENGTH_SHORT,
            gravity: ToastGravity.BOTTOM,);

        }
    );
  }
}
//时间胶囊按钮
class TimeButton extends StatelessWidget{
  final String token;
  TimeButton(this.token);
  Widget build (BuildContext context){
    return new IconButton(
        padding: EdgeInsets.all(0),
        iconSize: 70,
        icon: Image.network('https://static.easyicon.net/preview/121/1215875.gif'),
        onPressed:() {Navigator.push(context, new MaterialPageRoute(builder: (context) => new TimePage(this.token))
        );
        }
    );
  }
}
class SecondScreen extends StatelessWidget{
  Widget build(BuildContext context) {
    return MaterialApp(
        home: new Scaffold(
          body: Text('second'),
        )

    );
  }
}
